package com.lcy.struct.bTreePlus.disk.server;

import lombok.SneakyThrows;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * @author lucongyang
 * @date Created in  13:59
 * @description
 */
public class DatabaseClient {
    public static void main(String[] args) {
        new DatabaseClient().client();
    }
    @SneakyThrows
    public void client() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("等待连接服务端！");
        Socket socket = new Socket("127.0.0.1", 6033);
        System.out.println("连接服务端成功！");

        while (true) {
            // 给服务端发信息
            System.out.print("请输入：");
            String s = scanner.next();
            if ("out".equals(s)) {
                break;
            }
            OutputStream outputStream = socket.getOutputStream();
            socket.getOutputStream().write(s.getBytes(StandardCharsets.UTF_8));
        }
        socket.close();
    }
}
